/* ----------------------------------------------------------------------
*
* Copyright (C) 2025 XiaoFei. All rights reserved.
*
* $file:        XiaoFei_Usart.h
* $Date:        18-May-2025
* $Revision:    V1.2
* $Project:     XiaoFei BSP Library
*
* -------------------------------------------------------------------- */

#ifndef __XiaoFei_Usart_H
#define __XiaoFei_Usart_H

#define Usart_TX_GPIO                   GPIOA
#define Usart_TX_Pin                    GPIO_Pin_1
#define Usart_TX_RCC(x)                 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, (FunctionalState)x);
#define Usart_TX(x)                     GPIO_WriteBit(Usart_TX_GPIO,Usart_TX_Pin,(BitAction)(x))

#ifndef USARTBand_Typedef_def
#define USARTBand_Typedef_def
typedef enum {
    Band_4800   = 208,          /*!< The bandrate will be set at 4800 */
    Band_9600   = 104,          /*!< The bandrate will be set at 9600 */
    Band_19200  = 52,           /*!< The bandrate will be set at 19200 */
    Band_38400  = 26,           /*!< The bandrate will be set at 38400 */
    Band_57600  = 17            /*!< The bandrate will be set at 57600 */
} USARTBand_Typedef;
#endif

/* 
* @function:    Usart_Init
* @parameter:   [in]    Band                 The bandrate you need.
* @return:      None.
*/
void Usart_Init(USARTBand_Typedef Band);

/* 
* @function:    Usart_SendByte
* @parameter:   [in]    data                 The byte will be send.
* @return:      None.

*/
void Usart_SendByte(unsigned char data);

/* 
* @function:    Usart_SendString
* @parameter:   [in]    *String              The string will be send.
* @return:      None.
*/
void Usart_SendString(char *String);

/* 
* @function:    Usart_Printf
* @parameter:   [in]    *format              The parameter will be send in Usart_Printf.
* @return:      None.
*/
void Usart_Printf(char *format, ...);

#endif

